]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ShellWindowTracker: complete WM_CLASS fix
authorGiovanni Campagna <gcampagn@redhat.com>
Thu, 8 Aug 2013 08:40:01 +0000 (10:40 +0200)
committerGiovanni Campagna <gcampagn@redhat.com>
Thu, 8 Aug 2013 12:15:34 +0000 (14:15 +0200)
Chromium (but not google-chrome) has a StartupWMClass in the desktop
file, so we must match the instance part first to have chrome
web apps working.
Also, we must take care of apps without a wm_class or instance at
all.

https://bugzilla.gnome.org/show_bug.cgi?id=673657

src/shell-app-system.c
src/shell-window-tracker.c

index a6587bef644196b1b142923031db0bd76360d1e6..7f43bd4b03bebd1bc56c19544b27cfca34ade359 100644 (file)
@@ -541,7 +541,7 @@ shell_app_system_lookup_heuristic_basename (ShellAppSystem *system,
 /**
  * shell_app_system_lookup_desktop_wmclass:
  * @system: a #ShellAppSystem
- * @wmclass: A WM_CLASS value
+ * @wmclass: (allow-none): A WM_CLASS value
  *
  * Find a valid application whose .desktop file, without the extension
  * and properly canonicalized, matches @wmclass.
@@ -578,7 +578,7 @@ shell_app_system_lookup_desktop_wmclass (ShellAppSystem *system,
 /**
  * shell_app_system_lookup_startup_wmclass:
  * @system: a #ShellAppSystem
- * @wmclass: A WM_CLASS value
+ * @wmclass: (allow-none): A WM_CLASS value
  *
  * Find a valid application whose .desktop file contains a
  * StartupWMClass entry matching @wmclass.
@@ -589,6 +589,9 @@ ShellApp *
 shell_app_system_lookup_startup_wmclass (ShellAppSystem *system,
                                          const char     *wmclass)
 {
+  if (wmclass == NULL)
+    return NULL;
+
   return g_hash_table_lookup (system->priv->startup_wm_class_to_app, wmclass);
 }
 
index 09653e49b46521a9277d14a98513ec5eb135766b..e922cdd14ba6587d81a7c8ea665fd3636a826743 100644 (file)
@@ -225,31 +225,36 @@ get_app_from_window_wmclass (MetaWindow  *window)
      with
 
      StartupWMClass=crx_blpcfgokakmgnkcojhhkbfbldkacnbeo
-  */
 
-  /* first try a match from WM_CLASS to StartupWMClass */
-  wm_class = meta_window_get_wm_class (window);
-  app = shell_app_system_lookup_startup_wmclass (appsys, wm_class);
-  if (app != NULL)
-    return g_object_ref (app);
+     Note that chromium (but not google-chrome!) includes a StartupWMClass=chromium
+     in their .desktop file, so we must match the instance first.
+
+     Also note that in the good case (regular gtk+ app without hacks), instance and
+     class are the same except for case and there is no StartupWMClass at all.
+  */
 
-  /* then try a match from WM_CLASS (instance part) to StartupWMClass */
+  /* first try a match from WM_CLASS (instance part) to StartupWMClass */
   wm_instance = meta_window_get_wm_class_instance (window);
   app = shell_app_system_lookup_startup_wmclass (appsys, wm_instance);
   if (app != NULL)
     return g_object_ref (app);
 
-  /* then try a match from WM_CLASS to .desktop */
-  app = shell_app_system_lookup_desktop_wmclass (appsys, wm_class);
+  /* then try a match from WM_CLASS to StartupWMClass */
+  wm_class = meta_window_get_wm_class (window);
+  app = shell_app_system_lookup_startup_wmclass (appsys, wm_class);
   if (app != NULL)
     return g_object_ref (app);
 
-  /* finally, try a match from WM_CLASS (instance part) to .desktop
-     (unlikely to find anything at this point, but still worth a try) */
+  /* then try a match from WM_CLASS (instance part) to .desktop */
   app = shell_app_system_lookup_desktop_wmclass (appsys, wm_instance);
   if (app != NULL)
     return g_object_ref (app);
 
+  /* finally, try a match from WM_CLASS to .desktop */
+  app = shell_app_system_lookup_desktop_wmclass (appsys, wm_class);
+  if (app != NULL)
+    return g_object_ref (app);
+
   return NULL;
 }